﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

namespace SHDQGSWEB.Models
{
    public class HonorRepository
    {
        SHDQGSDBDataContext db = new SHDQGSDBDataContext();
        public IQueryable<Honor>  FindAllHonors()
        {
            return from honor in db.Honors
                   select honor;
        }

        public Honor FindHonor(int honorId)
        {
            
            return db.Honors.Single();
        }

        public bool Add(Honor honor)
        {
            try
            {
                db.Honors.InsertOnSubmit(honor);
            }
            catch (Exception)
            {

                return false;
            }
            return true;
        }

        public bool Delete(Honor honor)
        {
            try
            {
                db.Honors.DeleteOnSubmit(honor);
            }
            catch (Exception)
            {

                return false;
            }
            return true;
        }
        public bool Save()
        {
            try
            {
                db.SubmitChanges();
            }
            catch (Exception)
            {

                return false;
            }
            return true;
        }
    }
}